#[doc = "Register `TSENSOR_CTRL1` reader"]
pub struct R(crate::R<TSENSOR_CTRL1_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<TSENSOR_CTRL1_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<TSENSOR_CTRL1_SPEC>> for R {
    fn from(reader: crate::R<TSENSOR_CTRL1_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `TSENSOR_CTRL1` writer"]
pub struct W(crate::W<TSENSOR_CTRL1_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<TSENSOR_CTRL1_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::ops::DerefMut for W {
    #[inline(always)]
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
impl core::convert::From<crate::W<TSENSOR_CTRL1_SPEC>> for W {
    fn from(writer: crate::W<TSENSOR_CTRL1_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "TSensor IP Trim adjustment function source select.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TSENSOR_TEMP_TRIM_SEL_A {
    #[doc = "0: The temp_trim of the TSensor IP is directly loaded by the eFUSE."]
    BY_EFUSE = 0,
    #[doc = "1: The temp_trim of the TSensor IP is selected."]
    BY_REGISTER = 1,
}
impl From<TSENSOR_TEMP_TRIM_SEL_A> for bool {
    #[inline(always)]
    fn from(variant: TSENSOR_TEMP_TRIM_SEL_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `tsensor_temp_trim_sel` reader - TSensor IP Trim adjustment function source select."]
pub struct TSENSOR_TEMP_TRIM_SEL_R(crate::FieldReader<bool, TSENSOR_TEMP_TRIM_SEL_A>);
impl TSENSOR_TEMP_TRIM_SEL_R {
    pub(crate) fn new(bits: bool) -> Self {
        TSENSOR_TEMP_TRIM_SEL_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> TSENSOR_TEMP_TRIM_SEL_A {
        match self.bits {
            false => TSENSOR_TEMP_TRIM_SEL_A::BY_EFUSE,
            true => TSENSOR_TEMP_TRIM_SEL_A::BY_REGISTER,
        }
    }
    #[doc = "Checks if the value of the field is `BY_EFUSE`"]
    #[inline(always)]
    pub fn is_by_efuse(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_SEL_A::BY_EFUSE
    }
    #[doc = "Checks if the value of the field is `BY_REGISTER`"]
    #[inline(always)]
    pub fn is_by_register(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_SEL_A::BY_REGISTER
    }
}
impl core::ops::Deref for TSENSOR_TEMP_TRIM_SEL_R {
    type Target = crate::FieldReader<bool, TSENSOR_TEMP_TRIM_SEL_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `tsensor_temp_trim_sel` writer - TSensor IP Trim adjustment function source select."]
pub struct TSENSOR_TEMP_TRIM_SEL_W<'a> {
    w: &'a mut W,
}
impl<'a> TSENSOR_TEMP_TRIM_SEL_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: TSENSOR_TEMP_TRIM_SEL_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "The temp_trim of the TSensor IP is directly loaded by the eFUSE."]
    #[inline(always)]
    pub fn by_efuse(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_SEL_A::BY_EFUSE)
    }
    #[doc = "The temp_trim of the TSensor IP is selected."]
    #[inline(always)]
    pub fn by_register(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_SEL_A::BY_REGISTER)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u16) & 0x01) << 4);
        self.w
    }
}
#[doc = "Trim value for calibrating the TSensor IP temperature.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum TSENSOR_TEMP_TRIM_A {
    #[doc = "0: 0.000°C."]
    TRIM_P0P000 = 0,
    #[doc = "1: 1.410℃."]
    TRIM_P1P410 = 1,
    #[doc = "2: 2.820℃."]
    TRIM_P2P820 = 2,
    #[doc = "3: 4.230℃."]
    TRIM_P4P230 = 3,
    #[doc = "4: 5.640℃."]
    TRIM_P5P640 = 4,
    #[doc = "5: 7.050℃."]
    TRIM_P7P050 = 5,
    #[doc = "6: 8.460℃."]
    TRIM_P8P460 = 6,
    #[doc = "7: 9.870℃."]
    TRIM_P9P970 = 7,
    #[doc = "8: 0.000℃."]
    TRIM_N0P000 = 8,
    #[doc = "9: –1.410℃."]
    TRIM_N1P410 = 9,
    #[doc = "10: –2.820℃."]
    TRIM_N2P820 = 10,
    #[doc = "11: –4.230℃."]
    TRIM_N4P230 = 11,
    #[doc = "12: –5.640℃."]
    TRIM_N5P640 = 12,
    #[doc = "13: –7.050℃."]
    TRIM_N7P050 = 13,
    #[doc = "14: –8.460℃."]
    TRIM_N8P460 = 14,
    #[doc = "15: –9.870°C."]
    TRIM_N9P870 = 15,
}
impl From<TSENSOR_TEMP_TRIM_A> for u8 {
    #[inline(always)]
    fn from(variant: TSENSOR_TEMP_TRIM_A) -> Self {
        variant as _
    }
}
#[doc = "Field `tsensor_temp_trim` reader - Trim value for calibrating the TSensor IP temperature."]
pub struct TSENSOR_TEMP_TRIM_R(crate::FieldReader<u8, TSENSOR_TEMP_TRIM_A>);
impl TSENSOR_TEMP_TRIM_R {
    pub(crate) fn new(bits: u8) -> Self {
        TSENSOR_TEMP_TRIM_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> TSENSOR_TEMP_TRIM_A {
        match self.bits {
            0 => TSENSOR_TEMP_TRIM_A::TRIM_P0P000,
            1 => TSENSOR_TEMP_TRIM_A::TRIM_P1P410,
            2 => TSENSOR_TEMP_TRIM_A::TRIM_P2P820,
            3 => TSENSOR_TEMP_TRIM_A::TRIM_P4P230,
            4 => TSENSOR_TEMP_TRIM_A::TRIM_P5P640,
            5 => TSENSOR_TEMP_TRIM_A::TRIM_P7P050,
            6 => TSENSOR_TEMP_TRIM_A::TRIM_P8P460,
            7 => TSENSOR_TEMP_TRIM_A::TRIM_P9P970,
            8 => TSENSOR_TEMP_TRIM_A::TRIM_N0P000,
            9 => TSENSOR_TEMP_TRIM_A::TRIM_N1P410,
            10 => TSENSOR_TEMP_TRIM_A::TRIM_N2P820,
            11 => TSENSOR_TEMP_TRIM_A::TRIM_N4P230,
            12 => TSENSOR_TEMP_TRIM_A::TRIM_N5P640,
            13 => TSENSOR_TEMP_TRIM_A::TRIM_N7P050,
            14 => TSENSOR_TEMP_TRIM_A::TRIM_N8P460,
            15 => TSENSOR_TEMP_TRIM_A::TRIM_N9P870,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `TRIM_P0P000`"]
    #[inline(always)]
    pub fn is_trim_p0p000(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_P0P000
    }
    #[doc = "Checks if the value of the field is `TRIM_P1P410`"]
    #[inline(always)]
    pub fn is_trim_p1p410(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_P1P410
    }
    #[doc = "Checks if the value of the field is `TRIM_P2P820`"]
    #[inline(always)]
    pub fn is_trim_p2p820(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_P2P820
    }
    #[doc = "Checks if the value of the field is `TRIM_P4P230`"]
    #[inline(always)]
    pub fn is_trim_p4p230(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_P4P230
    }
    #[doc = "Checks if the value of the field is `TRIM_P5P640`"]
    #[inline(always)]
    pub fn is_trim_p5p640(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_P5P640
    }
    #[doc = "Checks if the value of the field is `TRIM_P7P050`"]
    #[inline(always)]
    pub fn is_trim_p7p050(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_P7P050
    }
    #[doc = "Checks if the value of the field is `TRIM_P8P460`"]
    #[inline(always)]
    pub fn is_trim_p8p460(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_P8P460
    }
    #[doc = "Checks if the value of the field is `TRIM_P9P970`"]
    #[inline(always)]
    pub fn is_trim_p9p970(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_P9P970
    }
    #[doc = "Checks if the value of the field is `TRIM_N0P000`"]
    #[inline(always)]
    pub fn is_trim_n0p000(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_N0P000
    }
    #[doc = "Checks if the value of the field is `TRIM_N1P410`"]
    #[inline(always)]
    pub fn is_trim_n1p410(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_N1P410
    }
    #[doc = "Checks if the value of the field is `TRIM_N2P820`"]
    #[inline(always)]
    pub fn is_trim_n2p820(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_N2P820
    }
    #[doc = "Checks if the value of the field is `TRIM_N4P230`"]
    #[inline(always)]
    pub fn is_trim_n4p230(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_N4P230
    }
    #[doc = "Checks if the value of the field is `TRIM_N5P640`"]
    #[inline(always)]
    pub fn is_trim_n5p640(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_N5P640
    }
    #[doc = "Checks if the value of the field is `TRIM_N7P050`"]
    #[inline(always)]
    pub fn is_trim_n7p050(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_N7P050
    }
    #[doc = "Checks if the value of the field is `TRIM_N8P460`"]
    #[inline(always)]
    pub fn is_trim_n8p460(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_N8P460
    }
    #[doc = "Checks if the value of the field is `TRIM_N9P870`"]
    #[inline(always)]
    pub fn is_trim_n9p870(&self) -> bool {
        **self == TSENSOR_TEMP_TRIM_A::TRIM_N9P870
    }
}
impl core::ops::Deref for TSENSOR_TEMP_TRIM_R {
    type Target = crate::FieldReader<u8, TSENSOR_TEMP_TRIM_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `tsensor_temp_trim` writer - Trim value for calibrating the TSensor IP temperature."]
pub struct TSENSOR_TEMP_TRIM_W<'a> {
    w: &'a mut W,
}
impl<'a> TSENSOR_TEMP_TRIM_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: TSENSOR_TEMP_TRIM_A) -> &'a mut W {
        self.bits(variant.into())
    }
    #[doc = "0.000°C."]
    #[inline(always)]
    pub fn trim_p0p000(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_P0P000)
    }
    #[doc = "1.410℃."]
    #[inline(always)]
    pub fn trim_p1p410(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_P1P410)
    }
    #[doc = "2.820℃."]
    #[inline(always)]
    pub fn trim_p2p820(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_P2P820)
    }
    #[doc = "4.230℃."]
    #[inline(always)]
    pub fn trim_p4p230(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_P4P230)
    }
    #[doc = "5.640℃."]
    #[inline(always)]
    pub fn trim_p5p640(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_P5P640)
    }
    #[doc = "7.050℃."]
    #[inline(always)]
    pub fn trim_p7p050(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_P7P050)
    }
    #[doc = "8.460℃."]
    #[inline(always)]
    pub fn trim_p8p460(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_P8P460)
    }
    #[doc = "9.870℃."]
    #[inline(always)]
    pub fn trim_p9p970(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_P9P970)
    }
    #[doc = "0.000℃."]
    #[inline(always)]
    pub fn trim_n0p000(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_N0P000)
    }
    #[doc = "–1.410℃."]
    #[inline(always)]
    pub fn trim_n1p410(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_N1P410)
    }
    #[doc = "–2.820℃."]
    #[inline(always)]
    pub fn trim_n2p820(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_N2P820)
    }
    #[doc = "–4.230℃."]
    #[inline(always)]
    pub fn trim_n4p230(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_N4P230)
    }
    #[doc = "–5.640℃."]
    #[inline(always)]
    pub fn trim_n5p640(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_N5P640)
    }
    #[doc = "–7.050℃."]
    #[inline(always)]
    pub fn trim_n7p050(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_N7P050)
    }
    #[doc = "–8.460℃."]
    #[inline(always)]
    pub fn trim_n8p460(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_N8P460)
    }
    #[doc = "–9.870°C."]
    #[inline(always)]
    pub fn trim_n9p870(self) -> &'a mut W {
        self.variant(TSENSOR_TEMP_TRIM_A::TRIM_N9P870)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !0x0f) | ((value as u16) & 0x0f);
        self.w
    }
}
impl R {
    #[doc = "Bit 4 - TSensor IP Trim adjustment function source select."]
    #[inline(always)]
    pub fn tsensor_temp_trim_sel(&self) -> TSENSOR_TEMP_TRIM_SEL_R {
        TSENSOR_TEMP_TRIM_SEL_R::new(((self.bits >> 4) & 0x01) != 0)
    }
    #[doc = "Bits 0:3 - Trim value for calibrating the TSensor IP temperature."]
    #[inline(always)]
    pub fn tsensor_temp_trim(&self) -> TSENSOR_TEMP_TRIM_R {
        TSENSOR_TEMP_TRIM_R::new((self.bits & 0x0f) as u8)
    }
}
impl W {
    #[doc = "Bit 4 - TSensor IP Trim adjustment function source select."]
    #[inline(always)]
    pub fn tsensor_temp_trim_sel(&mut self) -> TSENSOR_TEMP_TRIM_SEL_W {
        TSENSOR_TEMP_TRIM_SEL_W { w: self }
    }
    #[doc = "Bits 0:3 - Trim value for calibrating the TSensor IP temperature."]
    #[inline(always)]
    pub fn tsensor_temp_trim(&mut self) -> TSENSOR_TEMP_TRIM_W {
        TSENSOR_TEMP_TRIM_W { w: self }
    }
    #[doc = "Writes raw bits to the register."]
    pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "TSENSOR_CTRL1 is the TSensor control register 1.\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tsensor_ctrl1](index.html) module"]
pub struct TSENSOR_CTRL1_SPEC;
impl crate::RegisterSpec for TSENSOR_CTRL1_SPEC {
    type Ux = u16;
}
#[doc = "`read()` method returns [tsensor_ctrl1::R](R) reader structure"]
impl crate::Readable for TSENSOR_CTRL1_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [tsensor_ctrl1::W](W) writer structure"]
impl crate::Writable for TSENSOR_CTRL1_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets TSENSOR_CTRL1 to value 0"]
impl crate::Resettable for TSENSOR_CTRL1_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
